const gulp = require('gulp')
const sass = require('gulp-sass')

gulp.task('sass', function () {
  return new Promise((resolve, reject) => {
    gulp.src('src/scss/main.scss')
      .pipe(sass())
      .on('error', swallowError)
      .pipe(gulp.dest('src/css'))
    resolve()
  })
})

gulp.task('watch', function () {
  return new Promise((resolve, reject) => {
    gulp.watch('src/scss/**/*.scss', gulp.series('sass'))
    resolve()
  })
})

function swallowError (error) {
  console.error(error)
  this.emit('end')
}